#!/usr/bin/env python3

import sys
import pygame

def main(argv):
    pygame.init() # pygame初始化

    pygame.display.set_mode((600, 480)) # 创建600*480像素的窗口

    while True:
        e = pygame.event.wait()
        if e.type == pygame.QUIT:
            break # 键盘 “alt+f4” 或鼠标点 “x” 退出
        elif e.type == pygame.MOUSEMOTION:
            print('pos = ', e.pos) # 鼠标移动打印的坐标
        elif e.type == pygame.MOUSEBUTTONDOWN:
            print("button: ", e.button, ", pos = ", e.pos)
            # 鼠标点到地方打印的坐标
        elif e.type == pygame.KEYDOWN:
            if e.key == pygame.K_ESCAPE or e.key == pygame.K_q:
                break # 键盘按“Esc”或“q”退出

    pygame.quit() # 退出


if __name__ == '__main__':
    main(sys.argv)

